/*
 * @Author: 来自火星的码农 15122322+heyzhi@user.noreply.gitee.com
 * @Date: 2025-09-25 08:24:57
 * @LastEditors: 来自火星的码农 15122322+heyzhi@user.noreply.gitee.com
 * @LastEditTime: 2025-10-27 13:32:52
 * @FilePath: /GateServer/src/util/util.h
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
#pragma once
#include "string"
#include <functional>
namespace Yizhi {
    
    enum Ecode{
        SUCCESS=0,
        JSONFLASE=1001,
        RPCFLASE=1002,
        INVLIDINPUT=2001,
        PASSERROR=2002,
        VARIFY_CODE_EXPIRED=2003,
        VARIFY_CODE_INVAILD=2004,
        USEREXISTS=2005,
        USER_NOT_EXISTS=2006,
        UNKOWNERROR=5000

    };


    class Defer{
        public:
        typedef std::function<void()>  CallbackFun;
        Defer(CallbackFun func){m_func=func;}
        ~Defer(){
            if(m_func){
                m_func();
            }
           
        }

        Defer(const Defer& lhs)=delete;
        Defer& operator=(const Defer& lhs)=delete;
        private:
        CallbackFun  m_func;
    };


    static std::string Code_Prefix="code_";
}